VhlCfg / File / DesfireFileDesc Value

A VHL file can be composed of multiple files of a single desfire application. One list entry specifies the file settings of exactly one desfire file and contains one (or more) entries that describes how to access the desfire file and what part of the desfire file shall be accessed.

VHLReadWrite(): a Desfire application with two Desfire files of 50 bytes each could be mapped into single VHL file by specifing a DesfireFileDesc with two entries. The first entry maps desfire file 0 into the VHL file bytes 0-49 and the desfire file 1 is mapped by the second entry into the VHL file bytes 50-99. When reading VHL file bytes 48-52 the reader will implicitly read the last 2 bytes of desfire file 0 and the first two bytes of the desfire file 1 and return the concatenated result.

VHLFormat(): after executing VHLFormat() command all files should have the same settings as specified in the list entries. I.e. if a file already exists on card and the file settings of the card differ from the settings in the list entry, the existing file settings will be changed (success depends on access rights of the file). If file size is different the file will be deleted and created again. If a file exists on card but not in the file descriptor list it will be preserved. (e.g. on card exists file 1,2,5 - file descriptor contains file 1,2,6 - after execution of VHLFormat() the card contains file 1,2,5,6, files 1,2 have been adapted to new configuration values.

The last list entry may be specified incompletely. All missing data at the end of the entry will be assumed to have default values (This is only a convenience feature).

Properties

Format

Name Type/Size Description
DesfireFileDescList Array (until end of frame) -
DesfireFileDesc.FileNo Integer (8 bits) The DESFire file number to access
(Minimum value: 0, maximum value: 31)
DesfireFileDesc.FileCommunicationSecurity Enumeration (8 bits) Communication settings that define if data is to be MAC'ed or encrypted before it's transmitted to the host system.
Values:
  • Plain (0x00)
  • Mac (0x01)
  • Encrypted (0x03)
DesfireFileDesc.FileType Enumeration (8 bits) Type of file to read Only Standard and Backup files are supported. There's no support for Cyclic, Record, or Value files.
Values:
  • Standard (0x00)
  • Backup (0x01)
    Commit will be performed automatically.
  • BackupManualCommit (0x02)
    Commit will be performed when writing to address 0xFFFF.
DesfireFileDesc.ReadKeyNo Integer (8 bits)

ReadKeyNo, i.e. the index of the read key within the DESFire application key table

The value 14 allows unencrypted access.
(Minimum value: 0, maximum value: 14)
DesfireFileDesc.WriteKeyNo Integer (8 bits)

WriteKeyNo, i.e. the index of the write key within the DESFire application key table

The value 14 allows unencrypted access.
(Minimum value: 0, maximum value: 14)
DesfireFileDesc.Offset Integer (16 bits) Number of the first byte in the DESFire file to map into the VHL file.
(Minimum value: 0, maximum value: 0xFFFF)
DesfireFileDesc.Length Integer (16 bits) Length of byte sequence within the DESFire file to map into the VHL file.
(Minimum value: 0, maximum value: 0x7FFF)
DesfireFileDesc.ReadKeyIdx Integer (8 bits) Index of the read key on the reader
  1. 0x00-0x7F refer to an index in a SAM (key version has to be 0).
  2. 0x80-0xBF refer to an index in Crypto Key.
  3. 0xC0-0xCB refer to an index in VhlCfg/File/DesfireKeyList.
DesfireFileDesc.WriteKeyIdx Integer (8 bits) Index of the write key on the reader
If omitted and WriteKeyNo is equal to ReadKeyNo, it defaults to ReadKeyIdx. Otherwise it defaults to ReadKeyIdx + 1.
  1. 0x00-0x7F refer to an index in a SAM (key version has to be 0).
  2. 0x80-0xBF refer to an index in Crypto Key.
  3. 0xC0-0xCB refers to an index in VhlCfg/File/DesfireKeyList.
DesfireFileDesc.AccessRightsLowByte Integer (8 bits) Only needed to run VHL.Format.

This byte is composed of a high nibble ( ReadWriteKeyNo ) and a low nibble ( ChangeKeyNo ). It corresponds to the low byte of the access rights (see DESFire spec 3.5; chapter 8.3) of the DESFire file. The high byte is composed implicitly of ReadKeyNo and WriteKeyNo.

DesfireFileDesc.ChangeKeyIdx Integer (8 bits) Only needed to run VHL.Format.

Index of the key on the reader that is used to change a key when running VHL.Format. If ChangeKeyNo (see AccessRightsLowByte ) is equal to WriteKeyNo, this value defaults to WriteKeyIdx. Otherwise, it defaults to WriteKeyIdx + 1.

  1. 0x00-0x7F refer to an index in a SAM (key version has to be 0).
  2. 0x80-0xBF refer to an index in Crypto Key.
  3. 0xC0-0xCB refer to an index in VhlCfg/File/DesfireKeyList.
DesfireFileDesc.FileSize Integer (16 bits) Only needed to run VHL.Format.

The size of the DESfire file. It's usually Offset + Len.

DesfireFileDesc.IsoFid Integer (16 bits) Only needed to run VHL.Format.

ISO file identifier (ISO FID). If the card already contains a DESFire file with the same ISO FID, the existing file will be replaced. If this value is not specified (or 0x3F00), no ISO FID will be used.